package com.ruoyi.web.controller.ring.app;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ring.domain.dto.GeneralSecondDTO;
import com.ruoyi.ring.service.IHeartRateSecondService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 心率二级页 （APP）
 */
@Slf4j
@RestController
@RequestMapping("/ring/app/ring_heart_rate_second")
public class HeartRateSecondController extends BaseController
{
    @Resource
    private IHeartRateSecondService secondService;
    /**
     * 查询日历数据列表-app
     */
    @GetMapping("/query-calendar-list")
    public AjaxResult queryCalendarList(GeneralSecondDTO secondDTO){
        long userId = SecurityUtils.getUserId();
        log.info("查询日历数据列表: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryCalendarList(secondDTO));
    }
    /**
     * 二级页 心率平均值
     */
    @GetMapping("/query-heart-rate-average")
    public AjaxResult queryHeartRateAverage(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("心率平均值: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryHeartRateAverage(secondDTO));
    }
    /**
     * 二级页 运动期间心率
     */
    @GetMapping("/query-sport-heart-rate")
    public AjaxResult querySportHeartRate(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("运动期间心率: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.querySportHeartRate(secondDTO));
    }
    /**
     * 二级页 平均睡眠心率
     */
    @GetMapping("/query-sleep-heart-rate")
    public AjaxResult querySleepHeartRate(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("平均睡眠心率: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.querySleepHeartRate(secondDTO));
    }

    /**
     * 三级页 统计-手动测量记录
     */
    @GetMapping("/query-heart-rate-info")
    public AjaxResult queryHeartRateInfo(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("手动测量记录: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryHeartRateInfoList(secondDTO));
    }

    /**
     * 四级页 手动详情
     */
    @GetMapping("/query-heart-rate-detail/{id}")
    public AjaxResult queryHeartRateDetail(@PathVariable("id") Long id)
    {
        return AjaxResult.success(secondService.queryHeartRateDetail(id));
    }

    /**
     * 四级页 当天往前取7条数据
     */
    @GetMapping("/query-heart-rate-seven-info")
    public AjaxResult queryHeartRateSevenInfo(GeneralSecondDTO secondDTO)
    {
        long userId = SecurityUtils.getUserId();
        log.info("当天往前取7条数据: userId={}, param={}", userId, JSON.toJSONString(secondDTO));
        return AjaxResult.success(secondService.queryHeartRateSevenInfo(secondDTO));
    }


}
